package thread;

public class Demo13 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
           Thread current=Thread.currentThread();
           while (!current.isInterrupted()){
               System.out.println("hello thread");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                  // throw new RuntimeException(e);
                   System.out.println("执行到catch");
               }
           }
        });
        t.start();

        Thread.sleep(3000);
        //在主线程中，控制t 线程被终止，设置上述标志位
        t.interrupt();
    }
}
